{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Custom Display Logic"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Overview"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As described in the [Rich Output](Rich Output.ipynb) tutorial, the IPython display system can display rich representations of objects in the following formats:\n",
    "\n",
    "* JavaScript\n",
    "* HTML\n",
    "* PNG\n",
    "* JPEG\n",
    "* SVG\n",
    "* LaTeX\n",
    "* PDF\n",
    "\n",
    "This Notebook shows how you can add custom display logic to your own classes, so that they can be displayed using these rich representations. There are two ways of accomplishing this:\n",
    "\n",
    "1. Implementing special display methods such as `_repr_html_` when you define your class.\n",
    "2. Registering a display function for a particular existing class.\n",
    "\n",
    "This Notebook describes and illustrates both approaches."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Import the IPython display functions."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from IPython.display import (\n",
    "    display, display_html, display_png, display_svg\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Parts of this notebook need the matplotlib inline backend:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "plt.ion()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Special display methods"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The main idea of the first approach is that you have to implement special display methods when you define your class, one for each representation you want to use. Here is a list of the names of the special methods and the values they must return:\n",
    "\n",
    "* `_repr_html_`: return raw HTML as a string\n",
    "* `_repr_json_`: return a JSONable dict\n",
    "* `_repr_jpeg_`: return raw JPEG data\n",
    "* `_repr_png_`: return raw PNG data\n",
    "* `_repr_svg_`: return raw SVG data as a string\n",
    "* `_repr_latex_`: return LaTeX commands in a string surrounded by \"$\".\n",
    "* `_repr_mimebundle_`: return a full mimebundle containing the mapping from all mimetypes to data "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As an illustration, we build a class that holds data generated by sampling a Gaussian distribution with given mean and standard deviation. Here is the definition of the `Gaussian` class, which has a custom PNG and LaTeX representation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from IPython.core.pylabtools import print_figure\n",
    "from IPython.display import Image, SVG, Math\n",
    "\n",
    "class Gaussian(object):\n",
    "    \"\"\"A simple object holding data sampled from a Gaussian distribution.\n",
    "    \"\"\"\n",
    "    def __init__(self, mean=0.0, std=1, size=1000):\n",
    "        self.data = np.random.normal(mean, std, size)\n",
    "        self.mean = mean\n",
    "        self.std = std\n",
    "        self.size = size\n",
    "        # For caching plots that may be expensive to compute\n",
    "        self._png_data = None\n",
    "        \n",
    "    def _figure_data(self, format):\n",
    "        fig, ax = plt.subplots()\n",
    "        ax.hist(self.data, bins=50)\n",
    "        ax.set_title(self._repr_latex_())\n",
    "        ax.set_xlim(-10.0,10.0)\n",
    "        data = print_figure(fig, format)\n",
    "        # We MUST close the figure, otherwise IPython's display machinery\n",
    "        # will pick it up and send it as output, resulting in a double display\n",
    "        plt.close(fig)\n",
    "        return data\n",
    "        \n",
    "    def _repr_png_(self):\n",
    "        if self._png_data is None:\n",
    "            self._png_data = self._figure_data('png')\n",
    "        return self._png_data\n",
    "    \n",
    "    def _repr_latex_(self):\n",
    "        return r'$\\mathcal{N}(\\mu=%.2g, \\sigma=%.2g),\\ N=%d$' % (self.mean,\n",
    "                                                                 self.std, self.size)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Create an instance of the Gaussian distribution and return it to display the default representation:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image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2, \\sigma=1),\\ N=1000$"
      ],
      "text/plain": [
       "<__main__.Gaussian at 0x116fe76d8>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = Gaussian(2.0, 1.0)\n",
    "x"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can also pass the object to the `display` function to display the default representation:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEKCAYAAADzQPVvAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFOZJREFUeJzt3X+0ZWV93/H3xxnAVIlAGJCIOpiFFgxhMLMIDUlKxBB+\nuAQbtRiXmRaSadrQ6lrtSsayklJjW0ybaNommolQJ1k0QBWEBRidotaVtRLMID+EAPIjoyKEGRUQ\niDEi3/6x99Xj5dx7z73nnPtjnvdrrbPu2fvZe5/vPGfP5+zz7H33TVUhSdq3PWelC5AkTZ9hL0kN\nMOwlqQGGvSQ1wLCXpAYY9pLUAMNekhpg2EtSAwx7keTMJI8kuTjJf0ny9pWuabVJ8pkkr1zpOqSl\nMuwbkuTHkuw3a95zgFOAXwK+CvwC8AdTruOAJJck+UKSJ5LckuSMab7mCDVdkGRXkm8m+eCQRf4b\n8M4lbvvgJJXkz2fN/4Mk71nKNge2MW/dSQ5JcnWSp/r+/vlR2kZp19pi2LflPODsWfNOBq6qqmv7\n6Ruq6htTrmM98CXgHwMvAH4duDLJxim/7nweAt4FXDpH+7XATyc5Ygnb3gT8DXDsrPU3AbcuYXuD\nFqr794C/Bw4H3gK8b+Abynxto7RrDTHs23ICsHXWvJOAm/rnZwD/b7AxyYVJ3jcwfXCSbyV57lKL\nqKqnquqiqtpdVc9U1XXAXwM/utC6SfZL8p+S7O7rqP5x21Lr6Wu6qqo+QvftZlj73wE3A6ctYfOb\ngF3ATuB1AEnWAcc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yWN8A76T7cAJ4br/f3dfvhy9bgff5J+i+kt8+0I9nAr88\ns48CF/R9dxvdifAfX4E6h76Ps+oM3R85ur/fdzcvd519Hf+ALrxfMDBvxfuT7sPnYeBbfW6eT3eO\n6Ebg3v7nIf2ym4EPDKx7Xr+f3gf884Vey9slSFID/A1aSWqAYS9JDTDsJakBhr0kNcCwl6QGGPaS\n1ADDXpIa8P8BEb7Ae9JKdQAAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\mathcal{N}(\\mu=2, \\sigma=1),\\ N=1000$"
      ],
      "text/plain": [
       "<__main__.Gaussian at 0x116fe76d8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Use `display_png` to view the PNG representation:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEKCAYAAADzQPVvAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFOZJREFUeJzt3X+0ZWV93/H3xxnAVIlAGJCIOpiFFgxhMLMIDUlKxBB+\nuAQbtRiXmRaSadrQ6lrtSsayklJjW0ybaNommolQJ1k0QBWEBRidotaVtRLMID+EAPIjoyKEGRUQ\niDEi3/6x99Xj5dx7z73nnPtjnvdrrbPu2fvZe5/vPGfP5+zz7H33TVUhSdq3PWelC5AkTZ9hL0kN\nMOwlqQGGvSQ1wLCXpAYY9pLUAMNekhpg2EtSAwx7keTMJI8kuTjJf0ny9pWuabVJ8pkkr1zpOqSl\nMuwbkuTHkuw3a95zgFOAXwK+CvwC8AdTruOAJJck+UKSJ5LckuSMab7mCDVdkGRXkm8m+eCQRf4b\n8M4lbvvgJJXkz2fN/4Mk71nKNge2MW/dSQ5JcnWSp/r+/vlR2kZp19pi2LflPODsWfNOBq6qqmv7\n6Ruq6htTrmM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TmCS4C7qup35ljmhTPnEpKcSPd/+avLV+XI7+O1wC/0V+Wc\nBDw+M0SxAub85r4a+nPA4D44VwZ+DDgtycH9cO5p/by5TeHs8uvpPnW+CTwCfGyg7UK6qyHuAc4Y\nmH8D8IP985fRfQjcB/wf4IBJ1zhH3R8EfnnWvB8Ebhio67b+cSfdkMVyn7n/Y+BzwO39DnHE7Dr7\n6TPpruC4f7nr7N+3LwG39o/3z65xJftyWN8A76T7cAJ4br/f3dfvhy9bgff5J+i+kt8+0I9nAr88\ns48CF/R9dxvdifAfX4E6h76Ps+oM3R85ur/fdzcvd519Hf+ALrxfMDBvxfuT7sPnYeBbfW6eT3eO\n6Ebg3v7nIf2ym4EPDKx7Xr+f3gf884Vey9slSFID/A1aSWqAYS9JDTDsJakBhr0kNcCwl6QGGPaS\n1ADDXpIa8P8BEb7Ae9JKdQAAAAAASUVORK5CYII=\n"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display_png(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<div class=\"alert alert-success\">\n",
    "It is important to note a subtle different between <code>display</code> and <code>display_png</code>. The former computes <em>all</em> representations of the object, and lets the notebook UI decide which to display. The later only computes the PNG representation.\n",
    "</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Create a new Gaussian with different parameters:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEKCAYAAAAfGVI8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFmZJREFUeJzt3XuwZWV55/HvLzSgIkojDSIwNqbQEW/onCIkGoexHeRW\nglEyGEe7hAmjo4kmMxMw1MRUEmcwNzUzCaQjRrQokUEJjNEog1rOVA2YBrkKSIsIDS0cI+AtXojP\n/LFX63azz6X35exzeL+fql1n73e9a62n37V6P/t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YNxzqo9h7UN8Hv0khbAY7rzblt3Hj5tBu33Inrd/Bv62vB44A07z1HgzV27XU9vQv4XZhDn\n0GM4EGeAP+/a+0b6vkm4wrE+jt4b+xP7ymbenvQS0w7gh9375un05qSuBG7v/u7b1Z0D3tu37mnd\neboNeP1y9uctJiSpcathaEiSNEMmAklqnIlAkhpnIpCkxpkIJKlxJgJJapyJQJIa9/8B+rbuyM3h\nLnYAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\mathcal{N}(\\mu=0, \\sigma=2),\\ N=2000$"
      ],
      "text/plain": [
       "<__main__.Gaussian at 0x116fe7668>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x2 = Gaussian(0, 2, 2000)\n",
    "x2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can then compare the two Gaussians by displaying their histograms:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEKCAYAAADzQPVvAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFOZJREFUeJzt3X+0ZWV93/H3xxnAVIlAGJCIOpiFFgxhMLMIDUlKxBB+\nuAQbtRiXmRaSadrQ6lrtSsayklJjW0ybaNommolQJ1k0QBWEBRidotaVtRLMID+EAPIjoyKEGRUQ\niDEi3/6x99Xj5dx7z73nnPtjnvdrrbPu2fvZe5/vPGfP5+zz7H33TVUhSdq3PWelC5AkTZ9hL0kN\nMOwlqQGGvSQ1wLCXpAYY9pLUAMNekhpg2EtSAwx7keTMJI8kuTjJf0ny9pWuabVJ8pkkr1zpOqSl\nMuwbkuTHkuw3a95zgFOAXwK+CvwC8AdTruOAJJck+UKSJ5LckuSMab7mCDVdkGRXkm8m+eCQRf4b\n8M4lbvvgJJXkz2fN/4Mk71nKNge2MW/dSQ5JcnWSp/r+/vlR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/Bryuqv52\njmVWqi9H6Ztr6fY76PbDT8z1gTUt/TmCS4C7qup35ljmhTPnEpKcSPd/+avLV+XI7+O1wC/0V+Wc\nBDw+M0SxAub85r4a+nPA4D44VwZ+DDgtycH9cO5p/by5TeHs8uvpPnW+CTwCfGyg7UK6qyHuAc4Y\nmH8D8IP985fRfQjcB/wf4IBJ1zhH3R8EfnnWvB8Ebhio67b+cSfdkMVyn7n/Y+BzwO39DnHE7Dr7\n6TPpruC4f7nr7N+3LwG39o/3z65xJftyWN8A76T7cAJ4br/f3dfvhy9bgff5J+i+kt8+0I9nAr88\ns48CF/R9dxvdifAfX4E6h76Ps+oM3R85ur/fdzcvd519Hf+ALrxfMDBvxfuT7sPnYeBbfW6eT3eO\n6Ebg3v7nIf2ym4EPDKx7Xr+f3gf884Vey9slSFID/A1aSWqAYS9JDTDsJakBhr0kNcCwl6QGGPaS\n1ADDXpIa8P8BEb7Ae9JKdQAAAAAASUVORK5CYII=\n"
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEKCAYAAAAfGVI8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFmZJREFUeJzt3XuwZWV55/HvLzSgIkojDSIwNqbQEW/onCIkGoexHeRW\nglEyGEe7hAmjo4kmMxMw1MRUEmcwNzUzCaQjRrQokUEJjNEog1rOVA2YBrkKSIsIDS0cI+AtXojP\n/LFX63azz6X35exzeL+fql1n73e9a62n37V6P/t9373WTlUhSWrXz8w6AEnSbJkIJKlxJgJJapyJ\nQJIaZyKQpMaZCCSpcSYCSWqciUCSGmci0IKSHJ/kviTnJPlvSd4665hWmySfT/KsWcchjcNEIJL8\nXJLdB8p+Bjga+FXgH4DXAX+5ArHsm+TSJN9J8tUkvzLtfS4Sy55Jzu/i+FaSLyQ5bqDaHwO/N+L2\n1yepJP9voPwvk7xrmnEv1s5LHYPVdIw0GSYCAZwGnDRQ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"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display_png(x)\n",
    "display_png(x2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note that like `print`, you can call any of the `display` functions multiple times in a cell."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Adding IPython display support to existing objects"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When you are directly writing your own classes, you can adapt them for display in IPython by following the above approach.  But in practice, you often need to work with existing classes that you can't easily modify. We now illustrate how to add rich output capabilities to existing objects. We will use the NumPy polynomials and change their default representation to be a formatted LaTeX expression."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "First, consider how a NumPy polynomial object renders by default:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Polynomial([ 1.,  2.,  3.], [-10.,  10.], [-1,  1])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p = np.polynomial.Polynomial([1,2,3], [-10, 10])\n",
    "p"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Next, define a function that pretty-prints a polynomial as a LaTeX string:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def poly_to_latex(p):\n",
    "    terms = ['%.2g' % p.coef[0]]\n",
    "    if len(p) > 1:\n",
    "        term = 'x'\n",
    "        c = p.coef[1]\n",
    "        if c!=1:\n",
    "            term = ('%.2g ' % c) + term\n",
    "        terms.append(term)\n",
    "    if len(p) > 2:\n",
    "        for i in range(2, len(p)):\n",
    "            term = 'x^%d' % i\n",
    "            c = p.coef[i]\n",
    "            if c!=1:\n",
    "                term = ('%.2g ' % c) + term\n",
    "            terms.append(term)\n",
    "    px = '$P(x)=%s$' % '+'.join(terms)\n",
    "    dom = r', $x \\in [%.2g,\\ %.2g]$' % tuple(p.domain)\n",
    "    return px+dom"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This produces, on our polynomial ``p``, the following:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'$P(x)=1+2 x+3 x^2$, $x \\\\in [-10,\\\\ 10]$'"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "poly_to_latex(p)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can render this string using the `Latex` class:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$P(x)=1+2 x+3 x^2$, $x \\in [-10,\\ 10]$"
      ],
      "text/plain": [
       "<IPython.core.display.Latex object>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from IPython.display import Latex\n",
    "Latex(poly_to_latex(p))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "However, you can configure IPython to do this automatically by registering the `Polynomial` class and the `poly_to_latex` function with an IPython display formatter. Let's look at the default formatters provided by IPython:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              text/plain : PlainTextFormatter\n",
      "               text/html : HTMLFormatter\n",
      "           text/markdown : MarkdownFormatter\n",
      "           image/svg+xml : SVGFormatter\n",
      "               image/png : PNGFormatter\n",
      "         application/pdf : PDFFormatter\n",
      "              image/jpeg : JPEGFormatter\n",
      "              text/latex : LatexFormatter\n",
      "        application/json : JSONFormatter\n",
      "  application/javascript : JavascriptFormatter\n"
     ]
    }
   ],
   "source": [
    "ip = get_ipython()\n",
    "for mime, formatter in ip.display_formatter.formatters.items():\n",
    "    print('%24s : %s' % (mime, formatter.__class__.__name__))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The `formatters` attribute is a dictionary keyed by MIME types. To define a custom LaTeX display function, you want a handle on the `text/latex` formatter:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "ip = get_ipython()\n",
    "latex_f = ip.display_formatter.formatters['text/latex']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The formatter object has a couple of methods for registering custom display functions for existing types."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method for_type in module IPython.core.formatters:\n",
      "\n",
      "for_type(typ, func=None) method of IPython.core.formatters.LatexFormatter instance\n",
      "    Add a format function for a given type.\n",
      "    \n",
      "    Parameters\n",
      "    -----------\n",
      "    typ : type or '__module__.__name__' string for a type\n",
      "        The class of the object that will be formatted using `func`.\n",
      "    func : callable\n",
      "        A callable for computing the format data.\n",
      "        `func` will be called with the object to be formatted,\n",
      "        and will return the raw data in this formatter's format.\n",
      "        Subclasses may use a different call signature for the\n",
      "        `func` argument.\n",
      "        \n",
      "        If `func` is None or not specified, there will be no change,\n",
      "        only returning the current value.\n",
      "    \n",
      "    Returns\n",
      "    -------\n",
      "    oldfunc : callable\n",
      "        The currently registered callable.\n",
      "        If you are registering a new formatter,\n",
      "        this will be the previous value (to enable restoring later).\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(latex_f.for_type)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method for_type_by_name in module IPython.core.formatters:\n",
      "\n",
      "for_type_by_name(type_module, type_name, func=None) method of IPython.core.formatters.LatexFormatter instance\n",
      "    Add a format function for a type specified by the full dotted\n",
      "    module and name of the type, rather than the type of the object.\n",
      "    \n",
      "    Parameters\n",
      "    ----------\n",
      "    type_module : str\n",
      "        The full dotted name of the module the type is defined in, like\n",
      "        ``numpy``.\n",
      "    type_name : str\n",
      "        The name of the type (the class name), like ``dtype``\n",
      "    func : callable\n",
      "        A callable for computing the format data.\n",
      "        `func` will be called with the object to be formatted,\n",
      "        and will return the raw data in this formatter's format.\n",
      "        Subclasses may use a different call signature for the\n",
      "        `func` argument.\n",
      "        \n",
      "        If `func` is None or unspecified, there will be no change,\n",
      "        only returning the current value.\n",
      "    \n",
      "    Returns\n",
      "    -------\n",
      "    oldfunc : callable\n",
      "        The currently registered callable.\n",
      "        If you are registering a new formatter,\n",
      "        this will be the previous value (to enable restoring later).\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(latex_f.for_type_by_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In this case, we will use `for_type_by_name` to register `poly_to_latex` as the display function for the `Polynomial` type:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "latex_f.for_type_by_name('numpy.polynomial.polynomial',\n",
    "                                 'Polynomial', poly_to_latex)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Once the custom display function has been registered, all NumPy `Polynomial` instances will be represented by their LaTeX form instead:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$P(x)=1+2 x+3 x^2$, $x \\in [-10,\\ 10]$"
      ],
      "text/plain": [
       "Polynomial([ 1.,  2.,  3.], [-10.,  10.], [-1,  1])"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$P(x)=-20+71 x+-15 x^2+x^3$, $x \\in [-1,\\ 1]$"
      ],
      "text/plain": [
       "Polynomial([-20.,  71., -15.,   1.], [-1,  1], [-1,  1])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p2 = np.polynomial.Polynomial([-20, 71, -15, 1])\n",
    "p2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Custom Mimetypes with `_repr_mimebundle_`\n",
    "\n",
    "Available on IPython 5.4+ and 6.1+.\n",
    "\n",
    "For objects needing full control over the `repr` protocol may decide to implement the `_repr_mimebundle_(include, exclude)` method.\n",
    "Unlike the other `_repr_*_` methods must return many representation of the object in a mapping object which keys are _mimetypes_ and value are associated data. The `_repr_mimebundle_()` method, may also return a second mapping from _mimetypes_ to metadata. \n",
    "\n",
    "Example:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "class Gaussian(object):\n",
    "    \"\"\"A simple object holding data sampled from a Gaussian distribution.\n",
    "    \"\"\"\n",
    "    def __init__(self, mean=0.0, std=1, size=1000):\n",
    "        self.data = np.random.normal(mean, std, size)\n",
    "        self.mean = mean\n",
    "        self.std = std\n",
    "        self.size = size\n",
    "        # For caching plots that may be expensive to compute\n",
    "        self._png_data = None\n",
    "        \n",
    "    def _figure_data(self, format):\n",
    "        fig, ax = plt.subplots()\n",
    "        ax.hist(self.data, bins=50)\n",
    "        ax.set_xlim(-10.0,10.0)\n",
    "        data = print_figure(fig, format)\n",
    "        # We MUST close the figure, otherwise IPython's display machinery\n",
    "        # will pick it up and send it as output, resulting in a double display\n",
    "        plt.close(fig)\n",
    "        return data\n",
    "    \n",
    "    def _compute_mathml(self):\n",
    "        return \"\"\"\n",
    "        <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n",
    "          <mrow class=\"MJX-TeXAtom-ORD\">\n",
    "            <mi class=\"MJX-tex-caligraphic\" mathvariant=\"script\">N</mi>\n",
    "          </mrow>\n",
    "          <mo stretchy=\"false\">(</mo>\n",
    "          <mi>&#x03BC;<!-- μ --></mi>\n",
    "          <mo>=</mo>\n",
    "          <mn>{mu}</mn>\n",
    "          <mo>,</mo>\n",
    "          <mi>&#x03C3;<!-- σ --></mi>\n",
    "          <mo>=</mo>\n",
    "          <mn>{sigma}</mn>\n",
    "          <mo stretchy=\"false\">)</mo>\n",
    "          <mo>,</mo>\n",
    "          <mtext>&#xA0;</mtext>\n",
    "          <mi>N</mi>\n",
    "          <mo>=</mo>\n",
    "          <mn>{N}</mn>\n",
    "        </math>\n",
    "        \"\"\".format(N=self.size, mu=self.mean, sigma=self.std)\n",
    "        \n",
    "    def _repr_mimebundle_(self, include, exclude, **kwargs):\n",
    "        \"\"\"\n",
    "        repr_mimebundle should accept include, exclude and **kwargs\n",
    "        \"\"\"\n",
    "        if self._png_data is None:\n",
    "            self._png_data = self._figure_data('png')\n",
    "        math = r'$\\mathcal{N}(\\mu=%.2g, \\sigma=%.2g),\\ N=%d$' % (self.mean,\n",
    "                                                                 self.std, self.size)\n",
    "        data = {'image/png':self._png_data,\n",
    "                'text/latex':math,\n",
    "                'application/mathml+xml': self._compute_mathml()\n",
    "                }\n",
    "        if include:\n",
    "            data = {k:v for (k,v) in data.items() if k in include}\n",
    "        if exclude:\n",
    "            data = {k:v for (k,v) in data.items() if k not in exclude}\n",
    "        return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/mathml+xml": "\n        <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n          <mrow class=\"MJX-TeXAtom-ORD\">\n            <mi class=\"MJX-tex-caligraphic\" mathvariant=\"script\">N</mi>\n          </mrow>\n          <mo stretchy=\"false\">(</mo>\n          <mi>&#x03BC;<!-- μ --></mi>\n          <mo>=</mo>\n          <mn>0.0</mn>\n          <mo>,</mo>\n          <mi>&#x03C3;<!-- σ --></mi>\n          <mo>=</mo>\n          <mn>1</mn>\n          <mo stretchy=\"false\">)</mo>\n          <mo>,</mo>\n          <mtext>&#xA0;</mtext>\n          <mi>N</mi>\n          <mo>=</mo>\n          <mn>1000</mn>\n        </math>\n        ",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAD8CAYAAACW/ATfAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEftJREFUeJzt3X+MZWddx/H3x5aCQKVbOi0LZd2SNBU0oS2TBkUNsvwo\nlLDFUFJidIWaFQ0EYowskhgV/1g0/kxUstLKahBaCrUbWn6sSwkx0cK2tKVlW7etS1m77C4/SlES\ntPL1j3sWx/FO587cc++d2ef9Sib3nHPPueeb55753Geee86ZVBWSpJPbD8y6AEnS5Bn2ktQAw16S\nGmDYS1IDDHtJaoBhL0kNMOwlqQGGvSQ1wLCXpAacOs2dnXXWWbV58+Zp7lKS1r3bbrvta1U1N85r\nTDXsN2/ezP79+6e5S0la95J8edzXcBhHkhpg2EtSA5YN+yQXJLljwc+jSd6e5Mwke5Mc7B43TKNg\nSdLKLRv2VXVfVV1YVRcCLwC+A9wA7AD2VdX5wL5uXpK0Bq10GGcL8EBVfRnYCuzulu8GLu+zMElS\nf1Ya9lcCH+ymz6mqIwDd49l9FiZJ6s/IYZ/kNOA1wIdXsoMk25PsT7L/+PHjK61PktSDlfTsXwnc\nXlVHu/mjSTYCdI/Hhm1UVbuqar6q5ufmxromQJK0SisJ+zfwv0M4AHuAbd30NuDGvoqSJPVrpCto\nkzwZeBnwywsW7wSuS3IV8BBwRf/lSbO3ecdN358+tPOyGVYird5IYV9V3wGevmjZ1xmcnSNJWuO8\nglaSGmDYS1IDDHtJaoBhL0kNmOr97KW1xjNt1Ap79pLUAMNekhpg2EtSAwx7SWqAYS9JDTDsJakB\nhr0kNcCwl6QGGPaS1ADDXpIaYNhLUgMMe0lqgGEvSQ0w7CWpAYa9JDXAsJekBowU9knOSHJ9knuT\nHEjy40nOTLI3ycHuccOki5Ukrc6oPfs/BT5RVT8CPB84AOwA9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ec3g+8cbl9eQWtJDXAK2glqQGGvSQ1wLCXpAYY9pLUAMNekhpg2EtSAwx7SWqAYS9J\nDfgfS9fLKUqMYTsAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\mathcal{N}(\\mu=0, \\sigma=1),\\ N=1000$"
      ],
      "text/plain": [
       "<__main__.Gaussian at 0x11a614e80>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# that is definitively wrong as it should show the PNG. \n",
    "display(Gaussian())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the above example, the 3 mimetypes are embedded in the notebook document this allowing custom extensions and converters to display the representation(s) of their choice.\n",
    "\n",
    "For example, converting this noetebook to _epub_ may decide to use the MathML representation as most ebook reader cannot run mathjax (unlike browsers). \n",
    "\n",
    "\n",
    "### Implementation guidelines\n",
    "\n",
    "The `_repr_mimebundle_` methods is also given two keywords parameters :  `include` and `exclude`. Each can be a  containers (e.g.:`list`, `set` ...) of mimetypes to return or `None`, This allows implementation to avoid computing potentially unnecessary and expensive mimetypes representations. \n",
    "\n",
    "When `include` is non-empty (empty `list` or None), `_repr_mimebundle_` may decide to returns only the mimetypes in include.\n",
    "When `exclude` is non-empty, `_repr_mimebundle_` may decide to not return any mimetype in exclude. \n",
    "If both `include` and `exclude` and overlap, mimetypes present in exclude may not be returned. \n",
    "\n",
    "If implementations decide to ignore the `include` and `exclude` logic and always returns a full mimebundles, the IPython kernel will take care of removing non-desired representations.\n",
    "\n",
    "The `_repr_mimebundle_` method should accept arbitrary keyword arguments for future compatiility.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\mathcal{N}(\\mu=0, \\sigma=1),\\ N=1000$"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(Gaussian(), include={'text/latex'}) # only show latex"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/mathml+xml": "\n        <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n          <mrow class=\"MJX-TeXAtom-ORD\">\n            <mi class=\"MJX-tex-caligraphic\" mathvariant=\"script\">N</mi>\n          </mrow>\n          <mo stretchy=\"false\">(</mo>\n          <mi>&#x03BC;<!-- μ --></mi>\n          <mo>=</mo>\n          <mn>0.0</mn>\n          <mo>,</mo>\n          <mi>&#x03C3;<!-- σ --></mi>\n          <mo>=</mo>\n          <mn>1</mn>\n          <mo stretchy=\"false\">)</mo>\n          <mo>,</mo>\n          <mtext>&#xA0;</mtext>\n          <mi>N</mi>\n          <mo>=</mo>\n          <mn>1000</mn>\n        </math>\n        ",
      "text/latex": [
       "$\\mathcal{N}(\\mu=0, \\sigma=1),\\ N=1000$"
      ],
      "text/plain": [
       "<__main__.Gaussian at 0x116fe7550>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(Gaussian(), exclude={'image/png'}) # exclude png"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<__main__.Gaussian at 0x11a8a0b38>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(Gaussian(), include={'text/plain', 'image/png'}, exclude={'image/png'}) # keep only plain/text"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## More complex display with `_ipython_display_`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Rich output special methods and functions can only display one object or MIME type at a time. Sometimes this is not enough if you want to display multiple objects or MIME types at once. An example of this would be to use an HTML representation to put some HTML elements in the DOM and then use a JavaScript representation to add events to those elements.\n",
    "\n",
    "**IPython 2.0** recognizes another display method, `_ipython_display_`, which allows your objects to take complete control of displaying themselves. If this method is defined, IPython will call it, and make no effort to display the object using the above described `_repr_*_` methods for custom display functions. It's a way for you to say \"Back off, IPython, I can display this myself.\" Most importantly, your `_ipython_display_` method can make multiple calls to the top-level `display` functions to accomplish its goals.\n",
    "\n",
    "Here is an object that uses `display_html` and `display_javascript` to make a plot using the [Flot](http://www.flotcharts.org/) JavaScript plotting library:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import json\n",
    "import uuid\n",
    "from IPython.display import display_javascript, display_html, display\n",
    "\n",
    "class FlotPlot(object):\n",
    "    def __init__(self, x, y):\n",
    "        self.x = x\n",
    "        self.y = y\n",
    "        self.uuid = str(uuid.uuid4())\n",
    "    \n",
    "    def _ipython_display_(self):\n",
    "        json_data = json.dumps(list(zip(self.x, self.y)))\n",
    "        display_html('<div id=\"{}\" style=\"height: 300px; width:80%;\"></div>'.format(self.uuid),\n",
    "            raw=True\n",
    "        )\n",
    "        display_javascript(\"\"\"\n",
    "        require([\"//cdnjs.cloudflare.com/ajax/libs/flot/0.8.2/jquery.flot.min.js\"], function() {\n",
    "          var line = JSON.parse(\"%s\");\n",
    "          console.log(line);\n",
    "          $.plot(\"#%s\", [line]);\n",
    "        });\n",
    "        \"\"\" % (json_data, self.uuid), raw=True)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div id=\"c6929609-3cb6-4443-9574-d9f71791a987\" style=\"height: 300px; width:80%;\"></div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "\n",
       "        require([\"//cdnjs.cloudflare.com/ajax/libs/flot/0.8.2/jquery.flot.min.js\"], function() {\n",
       "          var line = JSON.parse(\"[[0.0, 0.0], [0.20408163265306123, 0.20266793654820095], [0.40816326530612246, 0.39692414892492234], [0.6122448979591837, 0.5747060412161791], [0.8163265306122449, 0.7286347834693503], [1.0204081632653061, 0.8523215697196184], [1.2244897959183674, 0.9406327851124867], [1.4285714285714286, 0.9899030763721239], [1.6326530612244898, 0.9980874821347183], [1.836734693877551, 0.9648463089837632], [2.0408163265306123, 0.8915592304110037], [2.2448979591836737, 0.7812680235262639], [2.4489795918367347, 0.6385503202266021], [2.6530612244897958, 0.469329612777201], [2.857142857142857, 0.28062939951435684], [3.0612244897959187, 0.0802816748428135], [3.2653061224489797, -0.12339813736217871], [3.4693877551020407, -0.3219563150726187], [3.673469387755102, -0.5071517094845144], [3.8775510204081636, -0.6712977935519321], [4.081632653061225, -0.8075816909683364], [4.285714285714286, -0.9103469443107828], [4.4897959183673475, -0.9753282860670456], [4.6938775510204085, -0.9998286683840896], [4.8979591836734695, -0.9828312039256306], [5.1020408163265305, -0.9250413717382029], [5.3061224489795915, -0.8288577363730427], [5.510204081632653, -0.6982723955653996], [5.714285714285714, -0.5387052883861563], [5.918367346938775, -0.35677924089893803], [6.122448979591837, -0.16004508604325057], [6.326530612244898, 0.04333173336868346], [6.530612244897959, 0.2449100710119793], [6.73469387755102, 0.4363234264718193], [6.938775510204081, 0.6096271964908323], [7.142857142857143, 0.7576284153927202], [7.346938775510204, 0.8741842988197335], [7.551020408163265, 0.9544571997387519], [7.755102040816327, 0.9951153947776636], [7.959183673469388, 0.9944713672636168], [8.16326530612245, 0.9525518475314604], [8.36734693877551, 0.8710967034823207], [8.571428571428571, 0.7534867274396376], [8.775510204081632, 0.6046033165061543], [8.979591836734695, 0.43062587038273736], [9.183673469387756, 0.23877531564403087], [9.387755102040817, 0.03701440148506237], [9.591836734693878, -0.1662827938487564], [9.795918367346939, -0.3626784288265488], [10.0, -0.5440211108893699]]\");\n",
       "          console.log(line);\n",
       "          $.plot(\"#c6929609-3cb6-4443-9574-d9f71791a987\", [line]);\n",
       "        });\n",
       "        "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "x = np.linspace(0,10)\n",
    "y = np.sin(x)\n",
    "FlotPlot(x, np.sin(x))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
